class MarketItem {
  final String name;
  final String code;
  double currentPrice;
  double change;
  double percentageChange;
  double buyPrice;
  double sellPrice;
  double yesterdayPrice;

  MarketItem({
    required this.name,
    required this.code,
    required this.currentPrice,
    required this.change,
    required this.percentageChange,
    required this.buyPrice,
    required this.sellPrice,
    required this.yesterdayPrice,
  });

  bool get isRising => change > 0;

  // 更新当前价格
  void updatePrice(double newPrice) {
    change = newPrice - currentPrice;
    percentageChange = (change / yesterdayPrice) * 100;
    currentPrice = newPrice;
    buyPrice = newPrice;
    sellPrice = newPrice + 0.01; // 假设卖价稍高
  }
}
